import 'core-js/stable'
import 'regenerator-runtime/runtime'
import Vue from 'vue'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import router from './router'
import store from './store/'
// import '../mock/mock.js'
import {
  VueAxios
} from './utils/request'

import Initializer from './core/Initializer'
import './core/lazyUse'
import './permission' // permission control
import './utils/filter' // global filter
import commonFun from './utils/common'
import api from './api/apilist' // 引入api
import * as echarts from 'echarts'
import chinaJson from './assets/json/china.json'
import i18n from './lang' // Internationalization
import './styles/index.less'
import Cookies from 'js-cookie'
import VueDraggableResizable from 'vue-draggable-resizable'
import tools from '@/utils/tools.js'
import Drawer from './components/Drawer/drawer'
import message from 'ant-design-vue/es/message'
import LoadingState from '@/components/SelfComponents/LoadingState.vue'
import AuthButton from '@/components/AuthButton'
import { STable } from '@/components'
import { managePerms } from '@/config/permission/index'

Vue.config.productionTip = false // 它会阻止你显示显示生产模式的消息
// mount axios Vue.$http and this.$http
Vue.use(VueAxios)
Vue.$store=store;
echarts.registerMap('china', chinaJson)
Vue.prototype.$echarts = echarts
Vue.prototype.$commonFun = commonFun
Vue.prototype.$api = api
// 备注等正则
Vue.prototype.$patternRemark = /^(?=.*?\S)[\s\S]{0,200}$/
Vue.prototype.$patternRemarkM = i18n.t('length300')
// 引入cookie工具包（主要用于跨平台cookie认证）
Vue.prototype.$Cookies = Cookies

Vue.prototype.$Tools = tools
Vue.prototype.$managePerms = managePerms
Vue.component('vue-draggable-resizable', VueDraggableResizable)
Vue.component('loading-state', LoadingState)
Vue.component('auth-button', AuthButton)
Vue.component('s-table', STable)

window.ssoSuccessCallBack = () =>{
  store.dispatch('GetInfo').then(() => {
    store.commit('toggleSsoLogin', false)
    message.success("登录成功，请重新加载/提交数据！");
  });
}
//Drawer清理：页签刷新时清除路由页面抽屉缓存
router.beforeEach((to, from, next) => {
  if (to.path === '/blank') {
    if (Drawer.close(from.fullPath) === false) {
      return;
    }
  }
  next();
});
new Vue({
  router,
  store,
  i18n,
  created () {
    Initializer()
  },
  render: h => h(App)
}).$mount('#app')
